import {connect}from 'react-redux'
import Chooseaddress from '../ui/chooseaddress'
import {setAddress} from '../actioncreater/goodsCreater'
const mapStateToProps=(state)=>{
    return {
        // restaurantId:'3307'
        shopinfo:state.cartReducer.currentshopinfo,
        currentshoplist:state.cartReducer.currentshoplist,
        currentshoptotal:state.cartReducer.currentshoplist.reduce((sum,val)=>{if(val.price==0){return sum}else{return sum+=val.num*val.price}},0),
        defaultaddress:state.cartReducer.defaultaddress
    }
}
const mapDispatchToProps=(dispatch)=>{
    return {
        chooseaddress(address){
            // console.log(currentshoplist)
             dispatch(setAddress(address))
        }
    }
}
export default connect(mapStateToProps,mapDispatchToProps)(Chooseaddress)